﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

#pragma once
#include "GnufExtension.h"

namespace gnuf
{
    class GnufTreeNodeData;
    class GnufRootNodeData;
    class GNUF_EXTENSION_EXPORT GnufTreeModelData
    {
    public:
        GnufTreeModelData() {}
        ~GnufTreeModelData() {}

    public:
        GnufRootNodeData* make(const std::wstring& name, const std::wstring& identity = std::wstring());
        GnufRootNodeData* rootNode();
        const GnufRootNodeData* rootNode() const;

    public:
        void setData(const std::wstring& key, const gcmp::Any& data);
        gcmp::Any& data(const std::wstring& key);
        const gcmp::Any& data(const std::wstring& key) const;

        GnufTreeNodeData* find(const std::wstring& identity);
        const GnufTreeNodeData* find(const std::wstring& identity) const;

        GnufTreeNodeData* findByPath(const std::wstring& path);
        const GnufTreeNodeData* findByPath(const std::wstring& path) const;

    private:
        GnufTreeModelData(const GnufTreeModelData&) = delete;
        GnufTreeModelData& operator=(const GnufTreeModelData&) = delete;

    private:
        gcmp::OwnerPtr<GnufRootNodeData> m_rootNode;
        std::map<std::wstring, gcmp::Any> m_data;
    };
}



